package Biet;

import java.util.Comparator;
import java.util.Objects;

class Card{
    public  String suit;
    public int rank;

    public Card(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }


    public int compareTo(Card o)
    {
        return this.rank-o.rank;
    }

    @Override
    public String toString() {
        return super.toString();
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return rank == card.rank && Objects.equals(suit, card.suit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(suit, rank);
    }
}
class SuitComparator implements Comparator<Card>{
    @Override
    public int compare(Card o1, Card o2) {
        return o1.suit.compareTo(o2.suit);
    }


}
public class bite {
    public static void main(String[] args) {
        Card card1 = new Card("hongtao",15);
        Card card2 = new Card("hongtao",5);

        System.out.println("==========");
        SuitComparator suitComparator =  new SuitComparator();
        if (suitComparator.compare(card1,card2) >0) {

            System.out.println("card1 > card2");
        }else {
            System.out.println("card1<=card2");
        }
    }
    public static void main2(String[] args) {
        Card card1 = new Card("hongtao",15);
        Card card2 = new Card("hongtao",5);
        if (card1.compareTo(card2) > 0) {

            System.out.println("card1 > card2");
        }else {
            System.out.println("card1<=card2");
        }
    }
    public static void main1(String[] args) {
        Card card1 = new Card("hongtao",15);
        Card card2 = new Card("heitao",5);
        System.out.println(card1.equals(card2));
    }
}
